home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / nntp1.5 / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-04-18  |  53.9 KB

  1. Subject:  v14i050:  Network News Transfer Protocol, version 1.5, Part04/09
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Phil Lapsley <phil@ucbvax.berkeley.edu>
  7. Posting-number: Volume 14, Issue 50
  8. Archive-name: nntp1.5/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 4 (of 9)."
  17. # Wrapped by rsalz@fig.bbn.com on Tue Apr 19 18:16:41 1988
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f './common/conf.h' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'./common/conf.h'\"
  21. else
  22. echo shar: Extracting \"'./common/conf.h'\" \(5753 characters\)
  23. sed "s/^X//" >'./common/conf.h' <<'END_OF_FILE'
  24. X/*
  25. X * Configuration information for use by NNTP server and support
  26. X * programs.  Change these as appropriate for your system.
  27. X */
  28. X
  29. X/*
  30. X * Compile time options.
  31. X */
  32. X
  33. X#undef    ALONE        /* True if we're running without inetd */
  34. X#undef    FASTFORK    /* True if we don't want to read active file on start */
  35. X#undef    BSD_42        /* 4.2 compatability code -- if this is defined, */
  36. X            /* DBM probably wants to be defined as well. */
  37. X
  38. X#define NDBM        /* Use new-style (4.3) ndbm(3x) libraries */
  39. X
  40. X#undef    DBM        /* True if we want to use the old dbm(3x) libraries */
  41. X            /* IF YOU DEFINE THIS, change CFLAGS in makefile to */
  42. X            /* be -ldbm */
  43. X
  44. X#undef    USGHIST        /* Use USG style history file (no DBM) */
  45. X            /* IF YOU DO NOT DEFINE NDBM or DBM, this is DEFAULT! */
  46. X
  47. X#undef    USG        /* System V support */
  48. X#undef    EXCELAN        /* Excelan EXOS 205 support */
  49. X
  50. X#undef U_LONG        /* Define this if your <sys/types.h> is missing */
  51. X            /* typedefs for u_long */
  52. X
  53. X/*
  54. X * If you DON'T have vfork, make this "#define vfork fork"
  55. X * vfork will speed up article transfer nntpds by about 2.5 times.
  56. X */
  57. X
  58. X#undef    vfork
  59. X
  60. X/*
  61. X * If you have the syslog library routine, define SYSLOG to
  62. X * be thef syslog facility name under which stats should be
  63. X * logged.  Newer 4.3 systems might choose LOG_NEWS;
  64. X * LOG_LOCAL7 is an acceptable substitute.
  65. X *
  66. X * If you don't have support for syslog, but want a facsimile,
  67. X * define FAKESYSLOG to be the name of a file to which to log stuff,
  68. X * then define SYSLOG and LOG, too.  e.g.,
  69. X *
  70. X *    #define    FAKESYSLOG    "/usr/lib/news/nntplog"
  71. X *
  72. X * If you don't want any syslog-type activity, #undef SYSLOG.
  73. X * Obviously, this means that you can't define LOG, either.
  74. X */
  75. X
  76. X#undef    FAKESYSLOG
  77. X
  78. X#define    SYSLOG    LOG_NEWS
  79. X
  80. X#ifdef SYSLOG        /* Define LOG if you want copious logging info */
  81. X#    define LOG    /* undef it if you don't */
  82. X#endif            /* but you can only have LOG if you have SYSLOG */
  83. X
  84. X#ifdef BSD_42        /* This is a logical, warranted assumption */
  85. X#   ifndef DBM        /* which will probably get me in trouble. */
  86. X#    define DBM    /* Kill it if you have 4.2 *and* ndbm.  */
  87. X#   endif not DBM
  88. X#endif BSD_42
  89. X
  90. X#ifdef USG        /* Another similar assumption */
  91. X#   ifndef USGHIST
  92. X#       define USGHIST
  93. X#   endif not USGHIST
  94. X#endif USG
  95. X
  96. X#undef    IHAVE_DEBUG    /* Copious debugging output from ihave */
  97. X
  98. X#define    XHDR        /* Optional XHDR command.  Defining this will */
  99. X            /* speed up '=' command in rn, but will load */
  100. X            /* the server more.  If your server is heavily */
  101. X            /* loaded already, defining this may be a bad idea */
  102. X
  103. X#define    SUBNET        /* If you have 4.3 subnetting */
  104. X#undef    DAMAGED_NETMASK    /* If your subnet mask is not a multiple of */
  105. X            /* four bits (e.g., UCSD) */
  106. X
  107. X#undef    NETMASK        /* If you don't have subnet ioctls, define */
  108. X            /* this to be a hex constant of your subnet */
  109. X            /* mask, e.g., #define NETMASK 0xffffff00 */
  110. X            /* Of course, you must define SUBNET above, too. */
  111. X#undef    DECNET        /* If you want decnet support */
  112. X
  113. X#define    GHNAME        /* Define if you have gethostname() */
  114. X#undef    UUNAME        /* Define to use /etc/uucpname */
  115. X            /* If neither of these are defined, */
  116. X            /* inews will use the contents of */
  117. X            /* /usr/include/whoami.h */
  118. X
  119. X/*
  120. X * System V compatability
  121. X */
  122. X
  123. X#ifdef USG
  124. X# define    FCNTL            /* If O_etc is defined in <fcntl.h> */
  125. X# define    NDIR            /* If you need ndir library support */
  126. X# define    index    strchr
  127. X# define    rindex    strrchr
  128. X# ifdef U_LONG
  129. X   typedef    unsigned long    u_long;
  130. X   typedef    unsigned short    u_short;
  131. X# endif U_LONG
  132. X# define    IPPORT_NNTP    119
  133. X#endif USG
  134. X
  135. X/*
  136. X * How long you want nntp servers to hang out without receiving
  137. X * commands before they close the connection with an error message.
  138. X *
  139. X * You CANNOT have TIMEOUT while running in standalone (ALONE) mode,
  140. X * as SIGALRM is used for different things.
  141. X *
  142. X * If you don't want any timeout, #undef it, i.e.,
  143. X *
  144. X *    #undef    TIMEOUT
  145. X *
  146. X * TIMEOUT should be at least two hours, which allows users some time
  147. X * away from their terminal (e.g., at lunch) while reading news.
  148. X */
  149. X
  150. X#ifndef ALONE
  151. X#    define    TIMEOUT    (2 * 3600)
  152. X#endif ALONE
  153. X
  154. X/*
  155. X * How long you want nntp servers to wait without receiving data
  156. X * during article transfers.  You CANNOT have XFER_TIMEOUT while
  157. X * running in standalond (ALONE) mode.
  158. X *
  159. X * If you don't want any transfer timeouts, #undef it, as above.
  160. X */
  161. X
  162. X#ifndef ALONE
  163. X#   define    XFER_TIMEOUT    (30 * 60)
  164. X#endif ALONE
  165. X
  166. X/*
  167. X * Your domain.  This is for the inews generated From: line,
  168. X * assuming that it doesn't find one in the article's head.
  169. X * Suggestions are .UUCP if you don't belong to the Internet.
  170. X * If your hostname returns the fully-qualified domain name
  171. X * as some 4.3 BSD systems do, simply undefine DOMAIN.
  172. X *
  173. X * e.g.  #define    DOMAIN        "berkeley.edu"
  174. X */
  175. X
  176. X#define    DOMAIN    "uucp"
  177. X
  178. X/*
  179. X * A file containing the name of the host which is running
  180. X * the news server.  This will have to match what rrn thinks,
  181. X * too.
  182. X */
  183. X
  184. X#define    SERVER_FILE    "/usr/local/lib/rn/server"
  185. X
  186. X/*
  187. X * Person (user name) to post news as.
  188. X */
  189. X
  190. X#define    POSTER        "news"
  191. X
  192. X/*
  193. X * These files are generated by the support programs, and are needed
  194. X * by the NNTP server.  Make sure that whatever directory you
  195. X * decide these files should go is writable by whatever uid you
  196. X * have the sypport programs run under.
  197. X */
  198. X
  199. X#define STAT_FILE    "/usr/lib/news/mgdstats"
  200. X#define NGDATE_FILE    "/usr/lib/news/groupdates"
  201. X
  202. X/*
  203. X * Some commonly used programs and files.
  204. X */
  205. X
  206. X#define    ACTIVE_FILE    "/usr/lib/news/active"
  207. X#define ACCESS_FILE    "/usr/lib/news/nntp_access"
  208. X#define HISTORY_FILE    "/usr/lib/news/history"
  209. X#define    SPOOLDIR    "/usr/spool/news"
  210. X#define INEWS        "/usr/lib/news/inews"
  211. X#define RNEWS        "/usr/bin/rnews"        /* Link to inews? */
  212. X
  213. X/*
  214. X * Some miscellaneous stuff you probably don't want to change.
  215. X */
  216. X
  217. X#define    MAX_ARTICLES    4096        /* Maximum number of articles/group */
  218. X#define READINTVL    60 * 10        /* 10 minutes b/n chking active file */
  219. END_OF_FILE
  220. if test 5753 -ne `wc -c <'./common/conf.h'`; then
  221.     echo shar: \"'./common/conf.h'\" unpacked with wrong size!
  222. fi
  223. # end of './common/conf.h'
  224. fi
  225. if test -f './doc/nntpd.dst' -a "${1}" != "-c" ; then 
  226.   echo shar: Will not clobber existing file \"'./doc/nntpd.dst'\"
  227. else
  228. echo shar: Extracting \"'./doc/nntpd.dst'\" \(5373 characters\)
  229. sed "s/^X//" >'./doc/nntpd.dst' <<'END_OF_FILE'
  230. X.\"
  231. X.\" @(#)nntpd.dst    1.3    (Berkeley) 10/15/87
  232. X.\"
  233. X.TH NNTPD 8C "8 July 1987"
  234. X.UC 4
  235. X.SH NAME
  236. nntpd \- Network News Transfer Protocol server
  237. X.SH SYNOPSIS
  238. X.B LNNTPD
  239. X.br
  240. X.I (with INETD, see below)
  241. X.SH DESCRIPTION
  242. X.I Nntpd
  243. is a server that supports the proposed standard
  244. for the stream based transmission of network
  245. news articles.
  246. It can be used both by ``reader/poster'' clients that
  247. present news to users, and by
  248. X``transfer'' clients that transport news between machines.
  249. When used with Internet TCP,
  250. X.I nntpd
  251. operates at the port indicated in the ``nntp'' service
  252. entry in
  253. X.IR SERVICES ;
  254. the port number assigned by the Network Information Center
  255. for this service is 119.
  256. For use with DECNET,
  257. xxx.
  258. This manual page describes
  259. X.I nntpd
  260. from version 1.4 of the NNTP package.
  261. X.PP
  262. X.I Nntpd
  263. can operate either as a stand-alone server, or as a
  264. server under
  265. X.IR inetd (1).
  266. For stand-alone use,
  267. X.I nntpd
  268. must be compiled with the -DALONE option, and is
  269. invoked as mentioned in the synopsis above.
  270. Under
  271. X.IR inetd (1),
  272. the appropriate entry must be made in
  273. X.IR INETDCONFIG ,
  274. and the server must be compiled without the
  275. X-DALONE flag.
  276. X.PP
  277. The server handles clients on a one to one basis,
  278. forking to take care of clients as they request
  279. connections.
  280. Each server changes its current
  281. directory to the news spool directory
  282. X(
  283. X.IR NEWSSPOOL )
  284. and then executes commands from its client.
  285. These commands are described in ARPA Internet
  286. RFC 977, ``Network News Transfer Protocol;
  287. A Proposed Standard for the Stream Based Transmission
  288. of News Articles.''
  289. X.SH "CLIENT ACCESS"
  290. X.PP
  291. Sites may choose to limit
  292. the hosts that can query the server for news.
  293. Further, some sites may not wish to allow
  294. certain hosts to post news.
  295. Finally, some sites may wish to restrict the newsgroups
  296. that can be accessed from remote hosts.
  297. Such limiting can be accomplished through an
  298. access file,
  299. X.IR NEWSLIB/nntp_access .
  300. This file consists of three or four fields in the following form:
  301. X.sp
  302. X.nf
  303. host/net        read/xfer/no    post/no        newsgroups
  304. X.fi
  305. X.sp
  306. where
  307. X.f
  308. X.I host
  309. is a valid host name as found in
  310. X.I HOSTFILE,
  311. X.I net
  312. is a valid network name as found in
  313. X.I NETWORKFILE,
  314. and
  315. X.I ``read'',
  316. X.I ``xfer'',
  317. X.I ``post'',
  318. and
  319. X.I ``no''
  320. are the corresponding string constants.
  321. X.I Newsgroups
  322. is an optional list of comma separated newsgroup names.
  323. Anything to the right of a `#' character
  324. is taken to be a comment and is ignored.
  325. X.PP
  326. The presence of an entry in this file
  327. implies that specific host, or
  328. hosts on the named network, are
  329. allowed to read news, but not to post news.
  330. The absence of a entry corresponding
  331. to a client's host or network implies that the client
  332. is not allowed to read or post news.
  333. Default permissions can be set by having the
  334. first entry in the file be a host/net name of
  335. X``default''.
  336. If this is used, ``default'' must be the
  337. first entry.
  338. X.PP
  339. The first field to the right of the host/net entry
  340. specifies the read access of the host/net in
  341. question.
  342. If the entry is ``read,'' matching
  343. hosts can both read and transfer news.
  344. If the entry is ``xfer,'' however,
  345. matching hosts can only execute commands
  346. used for transferring news, such as
  347. NEWNEWS, NEWGROUPS, IHAVE, and ARTICLE with message-id parameters.
  348. The string ``no'' denies read permission
  349. of any kind to a matching host.
  350. X.PP
  351. The next field to the right defines
  352. whether a matching host has post
  353. permission: if the field is ``post''
  354. then the POST command is permitted; if
  355. the field is ``no,'' then matching clients
  356. are not allowed to post news.
  357. X.PP
  358. The next field is optional, and, if present,
  359. is a comma separated list of newsgroup names
  360. that restrict the client's reading ability.
  361. Clients are not allowed to read or transfer
  362. articles in newsgroup names preceded by an exclamation
  363. point.
  364. By default, clients are allowed to read all newsgroups.
  365. X.PP
  366. X.I Nntpd
  367. is selective and searches for a ``best match''
  368. when searching this file to check its client's
  369. permissions.  That is, a specific host name
  370. match is used over a
  371. client being a member of a specified net.
  372. X.SH EXAMPLE ACCESS FILE
  373. X.PP
  374. X.sp
  375. X.nf
  376. X#
  377. X# Example access file
  378. X#
  379. default        xfer    no
  380. ucb-ether    read    post
  381. shadow        no    no
  382. ic        read    post    !ucb.postgres
  383. X.fi
  384. X.sp
  385. X.PP
  386. The above file allows only transfer of news (i.e., no reading or posting)
  387. by default.
  388. Hosts on the network ``ucb-ether'' would be able to
  389. read and post news.
  390. The host ``shadow'' would not be allowed
  391. to read or post news.
  392. Finally, the host ``ic'' is allowed to read and post
  393. news, but cannot access articles in the newsgroup
  394. X``ucb.postgres'' or any of its child newsgroups
  395. X(e.g., ``ucb.postgres.core'').
  396. X.SH "INFORMING USERS OF NEW NEWSGROUPS"
  397. X.PP
  398. The NEWGROUPS command has never worked very well because
  399. newsgroup creation dates are not stored under
  400. the USENET news system.
  401. As a result, it is left to client programs to determine
  402. by difference in active file size whether new groups exist,
  403. and if so, whether to inform the user of their existence.
  404. X.PP
  405. Older versions of
  406. X.I nntpd
  407. relied on the program
  408. X.I mkgrdates
  409. to prepare newsgroup creation information.
  410. X.I Mkgrdates
  411. was fallible and could present a hefty load
  412. on the serving system.
  413. Consequently, it is no longer supported, and its use is discouraged.
  414. X.SH AUTHOR
  415. Phil Lapsley (Internet: phil@berkeley.edu; UUCP: ...!ucbvax!phil)
  416. X.SH SEE ALSO
  417. services(5),
  418. inetd(8C)
  419. X.PP
  420. RFC 977, ``Network News Transfer Protocol:
  421. A Proposed Standard for the Stream Based Transmission
  422. of News Articles.''
  423. END_OF_FILE
  424. if test 5373 -ne `wc -c <'./doc/nntpd.dst'`; then
  425.     echo shar: \"'./doc/nntpd.dst'\" unpacked with wrong size!
  426. fi
  427. # end of './doc/nntpd.dst'
  428. fi
  429. if test -f './doc/nntpxmit.1' -a "${1}" != "-c" ; then 
  430.   echo shar: Will not clobber existing file \"'./doc/nntpxmit.1'\"
  431. else
  432. echo shar: Extracting \"'./doc/nntpxmit.1'\" \(5838 characters\)
  433. sed "s/^X//" >'./doc/nntpxmit.1' <<'END_OF_FILE'
  434. X.TH NNTPXMIT 1 netnews/NNTP
  435. X.SH NAME
  436. X.I nntpxmit
  437. X\- transmit netnews articles to a remote NNTP server
  438. X.SH SYNOPSIS
  439. X.I nntpxmit
  440. X[
  441. X.B \-a
  442. X]
  443. X[
  444. X.B \-d
  445. X]
  446. X[
  447. X.B \-s
  448. X]
  449. X[
  450. X.B \-r
  451. X]
  452. X[
  453. X.B \-T
  454. X]
  455. X[
  456. X.B \-F
  457. X]
  458. X[
  459. X.B \-D
  460. X] hostname|hostname:file [...]
  461. X.SH DESCRIPTION
  462. X.PP
  463. X.I Nntpxmit
  464. offers netnews articles [RFC850] named in a queue file (a file of
  465. filenames) to a remote NNTP (Network News Transfer Protocol,
  466. X[RFC977]) server, transmitting those articles that the remote server
  467. indicates that it does not already have.
  468. X.PP
  469. The command line arguments a processed sequentially, and the flags
  470. can thus be toggled several times during one invocation of the
  471. program, by giving the options more than once.
  472. The options are:
  473. X.IP hostname|hostname:file
  474. The name of the remote host, and the name of the queue file of
  475. articles destined for that host.
  476. The hostname may be an internet address in dotted
  477. format (e.g. 10.2.0.78, [10.0.0.78]).
  478. If the hostname is given without an associated file, it is assumed
  479. that the hostname is also the name of the queue file.
  480. If the separator is "::" instead of ":", it is assumed that the
  481. remote host speaks DECNET, instead of the default, IP/TCP.
  482. X.IP -s
  483. Toggles reporting of transfer statistics (how many articles we
  484. offered them, how many they accepted, etc).
  485. X.br
  486. Default is
  487. X.B ON.
  488. X.IP -d
  489. Toggles DEBUG output on stderr.
  490. This can be used to see exactly what the two systems are saying to
  491. each other, except for the actual article text.
  492. X.br
  493. Default is
  494. X.B OFF.
  495. X.IP -r
  496. Toggles requeuing of failed articles.
  497. A failed article is an article that we (client) offer them (remote server),
  498. they accept, we transmit, and then they report that they "failed"
  499. or dropped the article (i.e. inews(1) on the remote returned non-zero).
  500. If we have requeuing set, we save the list of articles that they
  501. failed on, and rewrite the queue file with them, so that they get
  502. reoffered the next time we initiate transmission to them.
  503. X.br
  504. Default is
  505. X.B ON.
  506. X.IP -a
  507. This flag says that the next queue file on the command line isn't
  508. a queue file, but is a single netnews
  509. article to be transmitted to the remote in a single operation.
  510. X.IP
  511. X.B NOTE:
  512. this option causes
  513. X.I nntpxmit
  514. to exit immediately after this transfer is done (regardless of
  515. whatever else is on the command line), and to exit with a code
  516. indicating whether the articles was successfully accepted by the
  517. remote server (zero exit for success, non-zero for failure).
  518. X.PP
  519. The next options set the underlying transport protocol that
  520. X.I nntpxmit
  521. uses.
  522. The NNTP specification assumes a TCP-style transport protocol
  523. underlies it (i.e. a reliable, flow-controlled, full-duplex byte
  524. stream).
  525. X.I Nntpxmit
  526. assumes that after doing some magic to get a descriptor, 
  527. it can do read(2) and write(2) calls (and use stdio) to move data
  528. and check for errors.
  529. By default, 
  530. X.I nntpxmit
  531. will use IP/TCP (DoD Internet Protocol suite).
  532. X.IP -T
  533. Sets transport protocol to IP/TCP for all remaining
  534. transfers (unless reset by other transport flags).
  535. Default transport.
  536. X.IP -D
  537. Sets transport protocol to DECNET for all remaining
  538. transfers (unless reset by other transport flags).
  539. X.B NOTE:
  540. using "::" as the hostname/queue filename separator has the
  541. same effect.
  542. X.IP -F
  543. This says that the hostname is a file descriptor number, already
  544. open to a remote server (with some reliable protocol underneath)
  545. that was passed to
  546. X.I nntpxmit
  547. through a fork(2).
  548. X.SH "THEORY OF OPERATION"
  549. X.PP
  550. X.I Nntpxmit
  551. implements an interactive ihave/sendme transmission system.
  552. Roughly, the protocol is
  553. X.IP 1.
  554. open the article,
  555. fetch out the message-id (required on all netnews articles),
  556. and send the command IHAVE <message-id> to the remote.
  557. X.IP 2.
  558. The remote will then say either "I've seen it already" or "please send
  559. that article to me."
  560. X.IP 3.
  561. If the response was negative,
  562. X.I nntpxmit
  563. loops back to step 1 and offers the next article (until queue file EOF).
  564. Otherwise,
  565. X.I nntpxmit
  566. will send the article, using SMTP [RFC821] text transmission conventions
  567. X(i.e. CRLF line terminators, and dot escaping).
  568. X.IP 4.
  569. X.I Nntpxmit
  570. waits for the remote to say whether the article was successfully
  571. accepted or not.
  572. If the answer is negative and requeuing of failed articles is enabled,
  573. X.I nntpxmit
  574. will queue this article's filename to be
  575. written back to the queue file at the end of the session with this
  576. remote.
  577. X.PP
  578. If the communcation link should fail (and
  579. X.I nntpxmit
  580. detects it through a system call error return),
  581. X.I nntpxmit
  582. will rewrite the queue file with the article filenames of the
  583. articles that it did not transmit (that is, we don't retransmit
  584. stuff we've already successfully sent and gotten back an positive
  585. confirmation that they got it).
  586. X.SH FILES
  587. X/tmp/nntpxmitXXXXXX
  588. X.SH AUTHOR
  589. Erik E. Fair
  590. X.SH "SEE ALSO"
  591. inews(1),
  592. X.br
  593. RFC977 \- Network News Transfer Protocol (NNTP),
  594. X.br
  595. RFC850 \- USENET Article Format standard,
  596. X.br
  597. RFC821 \- Simple Mail Transfer Protocol (SMTP),
  598. X.SH BUGS
  599. X.PP
  600. Always requeuing failed articles can lead to beating the remote to
  601. death with a list of articles that he can't accept for come structural
  602. reason.
  603. How many of these have to pile up before you should declare that
  604. something is seriously wrong with the remote system and stop trying?
  605. X.PP
  606. While
  607. X.B nntpxmit
  608. will lock a queue file (your version of UNIX permitting) against
  609. multiple invocations of itself, there is no locking with inews(1),
  610. which is what writes the queue files in the first place.
  611. Therefore, never use
  612. X.B nntpxmit
  613. on the queue files that inews(1) writes, because two processes
  614. writing into the same file without some kind of cooperation will
  615. almost certainly trash the file; move them to some other name that
  616. inews(1) knows nothing about, so that you won't lose articles to
  617. races between inews and nntpxmit.
  618. X.PP
  619. Adding inews(1) compatible locking to the C code would be much more
  620. trouble than it's worth, and violates the KISS principle besides.
  621. END_OF_FILE
  622. if test 5838 -ne `wc -c <'./doc/nntpxmit.1'`; then
  623.     echo shar: \"'./doc/nntpxmit.1'\" unpacked with wrong size!
  624. fi
  625. # end of './doc/nntpxmit.1'
  626. fi
  627. if test -f './inews/inews.c' -a "${1}" != "-c" ; then 
  628.   echo shar: Will not clobber existing file \"'./inews/inews.c'\"
  629. else
  630. echo shar: Extracting \"'./inews/inews.c'\" \(6070 characters\)
  631. sed "s/^X//" >'./inews/inews.c' <<'END_OF_FILE'
  632. X#ifndef lint
  633. static char *sccsid = "@(#)inews.c    1.15    (Berkeley) 2/6/88";
  634. X#endif
  635. X
  636. X/*
  637. X * Itty-bitty inews for talking to remote server.
  638. X * Simply accept input on stdin (or via a named file) and dump this
  639. X * to the server; add a From: and Path: line if missing in the original.
  640. X * Print meaningful errors from the server.
  641. X * Limit .signature files to MAX_SIGNATURE lines.
  642. X * No processing of command line options.
  643. X *
  644. X * Original by Steven Grady <grady@ucbvax.Berkeley.EDU>, with thanks from
  645. X * Phil Lapsley <phil@ucbvax.berkeley.edu>, who is now responsible for it.
  646. X */
  647. X
  648. X#include <stdio.h>
  649. X#include <pwd.h>
  650. X#include <ctype.h>
  651. X#include "../common/conf.h"
  652. X#include "../common/nntp.h"
  653. X#ifdef USG
  654. X#include <string.h>
  655. X#else not USG
  656. X#include <strings.h>
  657. X#endif not USG
  658. X
  659. X#define    MAX_SIGNATURE    4
  660. X
  661. extern    FILE    *ser_wr_fp;
  662. X
  663. char    host_name[256];
  664. X
  665. main(argc, argv)
  666. int    argc;
  667. char    *argv[];
  668. X{
  669. X    char    line[NNTP_STRLEN], s[NNTP_STRLEN];
  670. X    int    seen_fromline, in_header;
  671. X    int    response;
  672. X    char    *server;
  673. X    char    *getserverbyfile();
  674. X    register char    *cp;
  675. X
  676. X    ++argv;
  677. X    while (argc > 1)
  678. X        if (*argv[0] == '-') {
  679. X            ++argv;
  680. X            --argc;
  681. X        } else
  682. X            break;
  683. X
  684. X    if (argc > 1) {
  685. X        if (freopen(*argv, "r", stdin) == NULL) {
  686. X            perror(*argv);
  687. X            exit(1);
  688. X        }
  689. X    }
  690. X
  691. X    uname(host_name);
  692. X
  693. X    server = getserverbyfile(SERVER_FILE);
  694. X    if (server == NULL) {
  695. X        fprintf(stderr,
  696. X            "Can't get the name of the news server from %s.\n",
  697. X            SERVER_FILE);
  698. X        fprintf(stderr,
  699. X           "Either fix this file, or put NNTPSERVER in your enviroment.\n");
  700. X        exit(1);
  701. X    }
  702. X
  703. X    response = server_init(server);
  704. X    if (response < 0) {
  705. X        printf("Couldn't connect to %s news server, try again later.\n",
  706. X            server);
  707. X        exit(1);
  708. X    }
  709. X
  710. X    if (handle_server_response(response, server) < 0
  711. X        || response == OK_NOPOST) {
  712. X        close_server();
  713. X        exit(1);
  714. X    }
  715. X
  716. X    put_server("POST");
  717. X    (void) get_server(line, sizeof(line));
  718. X    if (*line != CHAR_CONT) {
  719. X        if (atoi(line) == ERR_NOPOST) {
  720. X            close_server();
  721. X            fprintf(stderr,
  722. X                "Sorry, you can't post from this machine.\n");
  723. X            exit(1);
  724. X        } else {
  725. X            close_server();
  726. X                fprintf(stderr, "Remote error: %s\n", line);
  727. X            exit(1);
  728. X        }
  729. X    }
  730. X
  731. X    in_header = 1;
  732. X    seen_fromline = 0;
  733. X
  734. X    while (gets(s) != NULL) {
  735. X        if (s[0] == '.')    /* Single . is eof, so put in extra one */
  736. X            (void) fputc('.', ser_wr_fp);
  737. X        if (in_header && strneql(s, "From:", sizeof("From:")-1))
  738. X            seen_fromline = 1;
  739. X        if (in_header && s[0] == '\0') {
  740. X            in_header = 0;
  741. X            if (!seen_fromline)
  742. X                gen_frompath();
  743. X        }
  744. X        fprintf(ser_wr_fp, "%s\r\n", s);
  745. X    }
  746. X
  747. X    append_signature();
  748. X
  749. X    fprintf(ser_wr_fp, ".\r\n");
  750. X    (void) fflush(ser_wr_fp);
  751. X    (void) get_server(line, sizeof(line));
  752. X    if (*line != CHAR_OK) {
  753. X        if (atoi(line) == ERR_POSTFAIL) {
  754. X            close_server();
  755. X            printf("Article not accepted by server; not posted.\n");
  756. X            for (cp = line + 4; *cp && *cp != '\r'; cp++)
  757. X                if (*cp == '\\')
  758. X                    putchar('\n');
  759. X                else
  760. X                    putchar(*cp);
  761. X            exit(1);
  762. X        } else {
  763. X            close_server();
  764. X            fprintf(stderr, "Remote error: %s\n", line);
  765. X            exit(1);
  766. X        }
  767. X    }
  768. X
  769. X    /*
  770. X     * Close server sends the server a
  771. X     * "quit" command for us, which is why we don't send it.
  772. X     */
  773. X
  774. X    close_server();
  775. X
  776. X    exit(0);
  777. X}
  778. X
  779. X/*
  780. X * append_signature -- append the person's .signature file if
  781. X * they have one.  Limit .signature to MAX_SIGNATURE lines.
  782. X */
  783. X
  784. append_signature()
  785. X{
  786. X    char    line[256], sigfile[256];
  787. X    char    *cp;
  788. X    struct    passwd    *passwd;
  789. X    FILE    *fp;
  790. X    char    *index();
  791. X    int    count = 0;
  792. X
  793. X    passwd = getpwuid(getuid());
  794. X    if (passwd == NULL)
  795. X        return;
  796. X
  797. X    (void) strcpy(sigfile, passwd->pw_dir);
  798. X    (void) strcat(sigfile, "/");
  799. X    (void) strcat(sigfile, ".signature");
  800. X
  801. X    fp = fopen(sigfile, "r");
  802. X    if (fp == NULL)
  803. X        return;
  804. X
  805. X    while (fgets(line, sizeof (line), fp)) {
  806. X        count++;
  807. X        if (count > MAX_SIGNATURE) {
  808. X            fprintf(stderr,
  809. X          "Warning: .signature files should be no longer than %d lines.\n",
  810. X            MAX_SIGNATURE);
  811. X            fprintf(stderr,
  812. X            "(Only %d lines of your .signature were posted.)\n",
  813. X            MAX_SIGNATURE);
  814. X            break;
  815. X        }
  816. X        if (cp = index(line, '\n'))
  817. X            *cp = '\0';
  818. X        fprintf(ser_wr_fp, "%s\r\n", line);
  819. X    }
  820. X    (void) fclose(fp);
  821. X}
  822. X
  823. X
  824. X/*
  825. X * gen_frompath -- generate From: and Path: lines, in the form
  826. X *
  827. X *    From: user@host.domain (full_name)
  828. X *    Path: host!user
  829. X *
  830. X * This routine should only be called if the message doesn't have
  831. X * a From: line in it.
  832. X */
  833. X
  834. gen_frompath()
  835. X{
  836. X    char    *full_name;
  837. X    char    *cp;
  838. X    struct    passwd *passwd;
  839. X    char    *index(), *getenv();
  840. X
  841. X    passwd = getpwuid(getuid());
  842. X
  843. X    full_name = getenv("NAME");
  844. X    if (full_name == NULL) {
  845. X        full_name = passwd->pw_gecos;
  846. X        if ((cp = index(full_name, ',')))
  847. X            *cp = '\0';
  848. X    }
  849. X
  850. X#ifdef DOMAIN
  851. X
  852. X    /* A heuristic to see if we should tack on a domain */
  853. X
  854. X    cp = index(host_name, '.');
  855. X    if (cp)
  856. X        fprintf(ser_wr_fp, "From: %s@%s (",
  857. X            passwd->pw_name,
  858. X            host_name);
  859. X    else
  860. X        fprintf(ser_wr_fp, "From: %s@%s.%s (",
  861. X            passwd->pw_name,
  862. X            host_name,
  863. X            DOMAIN);
  864. X#else
  865. X    fprintf(ser_wr_fp, "From: %s@%s (",
  866. X        passwd->pw_name,
  867. X        host_name);
  868. X#endif
  869. X
  870. X    for (cp = full_name; *cp != '\0'; ++cp)
  871. X        if (*cp != '&')
  872. X            putc(*cp, ser_wr_fp);
  873. X        else {        /* Stupid & hack.  God damn it. */
  874. X            putc(toupper(passwd->pw_name[0]), ser_wr_fp);
  875. X            fprintf(ser_wr_fp, passwd->pw_name+1);
  876. X        }
  877. X
  878. X    fprintf(ser_wr_fp, ")\r\n");
  879. X
  880. X    fprintf(ser_wr_fp, "Path: %s!%s\r\n", host_name, passwd->pw_name);
  881. X}
  882. X
  883. X
  884. X/*
  885. X * strneql -- determine if two strings are equal in the first n
  886. X * characters, ignoring case.
  887. X *
  888. X *    Parameters:    "a" and "b" are the pointers
  889. X *            to characters to be compared.
  890. X *            "n" is the number of characters to compare.
  891. X *
  892. X *    Returns:    1 if the strings are equal, 0 otherwise.
  893. X *
  894. X *    Side effects:    None.
  895. X */
  896. X
  897. strneql(a, b, n)
  898. register char *a, *b;
  899. int    n;
  900. X{
  901. X    char    lower();
  902. X
  903. X    while (n && lower(*a) == lower(*b)) {
  904. X        if (*a == '\0')
  905. X            return (1);
  906. X        a++;
  907. X        b++;
  908. X        n--;
  909. X    }
  910. X    if (n)
  911. X        return (0);
  912. X    else
  913. X        return (1);
  914. X}
  915. X
  916. X/*
  917. X * lower -- convert a character to lower case, if it's
  918. X *    upper case.
  919. X *
  920. X *    Parameters:    "c" is the character to be
  921. X *            converted.
  922. X *
  923. X *    Returns:    "c" if the character is not
  924. X *            upper case, otherwise the lower
  925. X *            case eqivalent of "c".
  926. X *
  927. X *    Side effects:    None.
  928. X */
  929. X
  930. char lower(c)
  931. register char c;
  932. X{
  933. X    if (isascii(c) && isupper(c))
  934. X        c = c - 'A' + 'a';
  935. X    return(c);
  936. X}
  937. END_OF_FILE
  938. if test 6070 -ne `wc -c <'./inews/inews.c'`; then
  939.     echo shar: \"'./inews/inews.c'\" unpacked with wrong size!
  940. fi
  941. # end of './inews/inews.c'
  942. fi
  943. if test -f './rrnpatches/newsetup.SH.pat' -a "${1}" != "-c" ; then 
  944.   echo shar: Will not clobber existing file \"'./rrnpatches/newsetup.SH.pat'\"
  945. else
  946. echo shar: Extracting \"'./rrnpatches/newsetup.SH.pat'\" \(4675 characters\)
  947. sed "s/^X//" >'./rrnpatches/newsetup.SH.pat' <<'END_OF_FILE'
  948. X*** rn/newsetup.SH    Sun Mar 15 19:54:40 1987
  949. X--- rrn/newsetup.SH    Thu Feb 25 20:35:26 1988
  950. X***************
  951. X*** 1,5
  952. X  case $CONFIG in
  953. X!     '') . config.sh ;;
  954. X  esac
  955. X  echo "Extracting newsetup (with variable substitutions)"
  956. X  $spitshell >newsetup <<!GROK!THIS!
  957. X
  958. X--- 1,5 -----
  959. X  case $CONFIG in
  960. X!     '') . ./config.sh ;;
  961. X  esac
  962. X  echo "Extracting newsetup (with variable substitutions)"
  963. X  $spitshell >newsetup <<!GROK!THIS!
  964. X***************
  965. X*** 32,38
  966. X  state="$statepref"
  967. X  cntry="$cntrypref"
  968. X  cont="$contpref"
  969. X! active="${active-/usr/lib/news/active}"
  970. X  
  971. X  dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
  972. X  $rm -f \$dotdir/.oldnewsrc
  973. X
  974. X--- 32,38 -----
  975. X  state="$statepref"
  976. X  cntry="$cntrypref"
  977. X  cont="$contpref"
  978. X! active="/tmp/active.\$\$"
  979. X  
  980. X  dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
  981. X  $rm -f \$dotdir/.oldnewsrc
  982. X***************
  983. X*** 38,46
  984. X  $rm -f \$dotdir/.oldnewsrc
  985. X  $echo "Creating .newsrc in \$dotdir to be used by news programs."
  986. X  
  987. X! case \$active in
  988. X! ~*) active=\`$filexp \$active\` ;;
  989. X! esac
  990. X  
  991. X  : NOTE: SED WILL NOT TAKE MORE THAN 10 WFILES, SO BEWARE
  992. X  
  993. X
  994. X--- 38,44 -----
  995. X  $rm -f \$dotdir/.oldnewsrc
  996. X  $echo "Creating .newsrc in \$dotdir to be used by news programs."
  997. X  
  998. X! $rnlib/getactive \$active
  999. X  
  1000. X  : NOTE: SED WILL NOT TAKE MORE THAN 10 WFILES, SO BEWARE
  1001. X  
  1002. X***************
  1003. X*** 58,71
  1004. X      -e "  w /tmp/n.test\$\$"    \\
  1005. X      -e '  d'            \\
  1006. X      -e '}'                \\
  1007. X-     -e "/^net\./{"            \\
  1008. X-     -e "  w /tmp/n.net\$\$"        \\
  1009. X-     -e '  d'            \\
  1010. X-     -e '}'                \\
  1011. X-     -e "/^mod\./{"            \\
  1012. X-     -e "  w /tmp/n.mod\$\$"        \\
  1013. X-     -e '  d'            \\
  1014. X-     -e '}'                \\
  1015. X      -e "/^\$locorg\./{"        \\
  1016. X      -e "  w /tmp/n.\$locorg\$\$"    \\
  1017. X      -e '  d'            \\
  1018. X
  1019. X--- 56,61 -----
  1020. X      -e "  w /tmp/n.test\$\$"    \\
  1021. X      -e '  d'            \\
  1022. X      -e '}'                \\
  1023. X      -e "/^\$locorg\./{"        \\
  1024. X      -e "  w /tmp/n.\$locorg\$\$"    \\
  1025. X      -e '  d'            \\
  1026. X***************
  1027. X*** 78,83
  1028. X      -e "  w /tmp/n.\$city\$\$"    \\
  1029. X      -e '  d'            \\
  1030. X      -e '}'                \\
  1031. X      -e "/^\$state\./{"         \\
  1032. X      -e "  w /tmp/n.\$state\$\$"    \\
  1033. X      -e '  d'            \\
  1034. X
  1035. X--- 68,77 -----
  1036. X      -e "  w /tmp/n.\$city\$\$"    \\
  1037. X      -e '  d'            \\
  1038. X      -e '}'                \\
  1039. X+     -e "/^\$cntry\./{"         \\
  1040. X+     -e "  w /tmp/n.\$cntry\$\$"    \\
  1041. X+     -e '  d'            \\
  1042. X+     -e '}'                \\
  1043. X      -e "/^\$state\./{"         \\
  1044. X      -e "  w /tmp/n.\$state\$\$"    \\
  1045. X      -e '  d'            \\
  1046. X***************
  1047. X*** 81,90
  1048. X      -e "/^\$state\./{"         \\
  1049. X      -e "  w /tmp/n.\$state\$\$"    \\
  1050. X      -e '  d'            \\
  1051. X-     -e '}'                \\
  1052. X-     -e "/^fa\./{"            \\
  1053. X-     -e "  w /tmp/n.fa\$\$"        \\
  1054. X-     -e '  d'            \\
  1055. X      -e '}'
  1056. X  
  1057. X  $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  1058. X
  1059. X--- 75,80 -----
  1060. X      -e "/^\$state\./{"         \\
  1061. X      -e "  w /tmp/n.\$state\$\$"    \\
  1062. X      -e '  d'            \\
  1063. X      -e '}'
  1064. X  
  1065. X  $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  1066. X***************
  1067. X*** 88,97
  1068. X      -e '}'
  1069. X  
  1070. X  $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  1071. X-     -e "/^\$cntry\./{"         \\
  1072. X-     -e "  w /tmp/n.\$cntry\$\$"    \\
  1073. X-     -e '  d'            \\
  1074. X-     -e '}'                \\
  1075. X      -e "/^\$cont\./{"         \\
  1076. X      -e "  w /tmp/n.\$cont\$\$"    \\
  1077. X      -e '  d'            \\
  1078. X
  1079. X--- 78,83 -----
  1080. X      -e '}'
  1081. X  
  1082. X  $sed </tmp/n.tmp\$\$ >/tmp/n.local\$\$    \\
  1083. X      -e "/^\$cont\./{"         \\
  1084. X      -e "  w /tmp/n.\$cont\$\$"    \\
  1085. X      -e '  d'            \\
  1086. X***************
  1087. X*** 144,150
  1088. X      /tmp/n.\$state\$\$ \\
  1089. X      /tmp/n.\$cntry\$\$ \\
  1090. X      /tmp/n.\$cont\$\$ \\
  1091. X-     /tmp/n.mod\$\$ \\
  1092. X      /tmp/n.news\$\$ \\
  1093. X      /tmp/n.comp\$\$ \\
  1094. X      /tmp/n.sci\$\$ \\
  1095. X
  1096. X--- 130,135 -----
  1097. X      /tmp/n.\$state\$\$ \\
  1098. X      /tmp/n.\$cntry\$\$ \\
  1099. X      /tmp/n.\$cont\$\$ \\
  1100. X      /tmp/n.news\$\$ \\
  1101. X      /tmp/n.comp\$\$ \\
  1102. X      /tmp/n.sci\$\$ \\
  1103. X***************
  1104. X*** 152,159
  1105. X      /tmp/n.soc\$\$ \\
  1106. X      /tmp/n.misc\$\$ \\
  1107. X      /tmp/n.talk\$\$ \\
  1108. X-     /tmp/n.net\$\$ \\
  1109. X-     /tmp/n.fa\$\$ \\
  1110. X      /tmp/n.test\$\$ \\
  1111. X  | $uniq >\$dotdir/.newsrc
  1112. X  
  1113. X
  1114. X--- 137,142 -----
  1115. X      /tmp/n.soc\$\$ \\
  1116. X      /tmp/n.misc\$\$ \\
  1117. X      /tmp/n.talk\$\$ \\
  1118. X      /tmp/n.test\$\$ \\
  1119. X  | $uniq >\$dotdir/.newsrc
  1120. X  
  1121. X***************
  1122. X*** 166,172
  1123. X      /tmp/n.\$state\$\$ \\
  1124. X      /tmp/n.\$cntry\$\$ \\
  1125. X      /tmp/n.\$cont\$\$ \\
  1126. X-     /tmp/n.mod\$\$ \\
  1127. X      /tmp/n.news\$\$ \\
  1128. X      /tmp/n.comp\$\$ \\
  1129. X      /tmp/n.sci\$\$ \\
  1130. X
  1131. X--- 149,154 -----
  1132. X      /tmp/n.\$state\$\$ \\
  1133. X      /tmp/n.\$cntry\$\$ \\
  1134. X      /tmp/n.\$cont\$\$ \\
  1135. X      /tmp/n.news\$\$ \\
  1136. X      /tmp/n.comp\$\$ \\
  1137. X      /tmp/n.sci\$\$ \\
  1138. X***************
  1139. X*** 173,180
  1140. X      /tmp/n.soc\$\$ \\
  1141. X      /tmp/n.rec\$\$ \\
  1142. X      /tmp/n.talk\$\$ \\
  1143. X-     /tmp/n.net\$\$ \\
  1144. X-     /tmp/n.fa\$\$ \\
  1145. X      /tmp/n.misc\$\$ \\
  1146. X      /tmp/n.test\$\$
  1147. X  
  1148. X
  1149. X--- 155,160 -----
  1150. X      /tmp/n.soc\$\$ \\
  1151. X      /tmp/n.rec\$\$ \\
  1152. X      /tmp/n.talk\$\$ \\
  1153. X      /tmp/n.misc\$\$ \\
  1154. X      /tmp/n.test\$\$ \\
  1155. X      \$active
  1156. X***************
  1157. X*** 176,182
  1158. X      /tmp/n.net\$\$ \\
  1159. X      /tmp/n.fa\$\$ \\
  1160. X      /tmp/n.misc\$\$ \\
  1161. X!     /tmp/n.test\$\$
  1162. X  
  1163. X  $cat <<'EOH'
  1164. X  Done.
  1165. X
  1166. X--- 156,163 -----
  1167. X      /tmp/n.rec\$\$ \\
  1168. X      /tmp/n.talk\$\$ \\
  1169. X      /tmp/n.misc\$\$ \\
  1170. X!     /tmp/n.test\$\$ \\
  1171. X!     \$active
  1172. X  
  1173. X  $cat <<'EOH'
  1174. X  Done.
  1175. END_OF_FILE
  1176. if test 4675 -ne `wc -c <'./rrnpatches/newsetup.SH.pat'`; then
  1177.     echo shar: \"'./rrnpatches/newsetup.SH.pat'\" unpacked with wrong size!
  1178. fi
  1179. # end of './rrnpatches/newsetup.SH.pat'
  1180. fi
  1181. if test -f './rrnpatches/ng.c.pat' -a "${1}" != "-c" ; then 
  1182.   echo shar: Will not clobber existing file \"'./rrnpatches/ng.c.pat'\"
  1183. else
  1184. echo shar: Extracting \"'./rrnpatches/ng.c.pat'\" \(5064 characters\)
  1185. sed "s/^X//" >'./rrnpatches/ng.c.pat' <<'END_OF_FILE'
  1186. X*** rn/ng.c    Sun Mar 15 19:54:26 1987
  1187. X--- rrn/ng.c    Mon May 25 22:41:53 1987
  1188. X***************
  1189. X*** 48,53
  1190. X  #include "rcln.h"
  1191. X  #include "last.h"
  1192. X  #include "search.h"
  1193. X  #include "INTERN.h"
  1194. X  #include "ng.h"
  1195. X  #include "artstate.h"            /* somebody has to do it */
  1196. X
  1197. X--- 48,54 -----
  1198. X  #include "rcln.h"
  1199. X  #include "last.h"
  1200. X  #include "search.h"
  1201. X+ #include "server.h"
  1202. X  #include "INTERN.h"
  1203. X  #include "ng.h"
  1204. X  #include "artstate.h"            /* somebody has to do it */
  1205. X***************
  1206. X*** 110,115
  1207. X  do_newsgroup(start_command)
  1208. X  char *start_command;            /* command to fake up first */
  1209. X  {
  1210. X      char oldmode = mode;
  1211. X      register long i;            /* scratch */
  1212. X      int skipstate;            /* how many unavailable articles */
  1213. X
  1214. X--- 111,121 -----
  1215. X  do_newsgroup(start_command)
  1216. X  char *start_command;            /* command to fake up first */
  1217. X  {
  1218. X+ #ifdef SERVER
  1219. X+     char ser_line[256];
  1220. X+     char artname[32];
  1221. X+     static long our_pid;
  1222. X+ #endif SERVER
  1223. X      char oldmode = mode;
  1224. X      register long i;            /* scratch */
  1225. X      int skipstate;            /* how many unavailable articles */
  1226. X***************
  1227. X*** 117,122
  1228. X      
  1229. X      char *whatnext = "%sWhat next? [%s]";
  1230. X  
  1231. X  #ifdef ARTSEARCH
  1232. X      srchahead = (scanon && ((ART_NUM)toread[ng]) >= scanon ? -1 : 0);
  1233. X                      /* did they say -S? */
  1234. X
  1235. X--- 123,133 -----
  1236. X      
  1237. X      char *whatnext = "%sWhat next? [%s]";
  1238. X  
  1239. X+ #ifdef SERVER
  1240. X+     if (our_pid == 0)           /* Agreed, this is gross */
  1241. X+         our_pid = getpid();
  1242. X+ #endif SERVER
  1243. X+ 
  1244. X  #ifdef ARTSEARCH
  1245. X      srchahead = (scanon && ((ART_NUM)toread[ng]) >= scanon ? -1 : 0);
  1246. X                      /* did they say -S? */
  1247. X***************
  1248. X*** 125,130
  1249. X      mode = 'a';
  1250. X      recent_art = curr_art = 0;
  1251. X      exit_code = NG_NORM;
  1252. X      if (eaccess(ngdir,5)) {        /* directory read protected? */
  1253. X      if (eaccess(ngdir,0)) {
  1254. X  #ifdef VERBOSE
  1255. X
  1256. X--- 136,156 -----
  1257. X      mode = 'a';
  1258. X      recent_art = curr_art = 0;
  1259. X      exit_code = NG_NORM;
  1260. X+ 
  1261. X+ #ifdef SERVER
  1262. X+     sprintf(ser_line, "GROUP %s", ngname);
  1263. X+     put_server(ser_line);
  1264. X+     if (get_server(ser_line, sizeof(ser_line)) < 0) {
  1265. X+     fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  1266. X+     finalize(1);
  1267. X+     }
  1268. X+     if (*ser_line != CHAR_OK) {
  1269. X+     if (atoi(ser_line) != ERR_NOGROUP)
  1270. X+         fprintf(stderr, "rrn: server response to GROUP %s:\n%s\n",
  1271. X+             ngname, ser_line);
  1272. X+     return (-1);
  1273. X+     }
  1274. X+ #else not SERVER
  1275. X      if (eaccess(ngdir,5)) {        /* directory read protected? */
  1276. X      if (eaccess(ngdir,0)) {
  1277. X  #ifdef VERBOSE
  1278. X***************
  1279. X*** 165,170
  1280. X      mode = oldmode;
  1281. X      return -1;
  1282. X      }
  1283. X  
  1284. X  #ifdef CACHESUBJ
  1285. X      subj_list = Null(char **);        /* no subject list till needed */
  1286. X
  1287. X--- 191,197 -----
  1288. X      mode = oldmode;
  1289. X      return -1;
  1290. X      }
  1291. X+ #endif SERVER
  1292. X  
  1293. X  #ifdef CACHESUBJ
  1294. X      subj_list = Null(char **);        /* no subject list till needed */
  1295. X***************
  1296. X*** 293,298
  1297. X      else if
  1298. X        (!reread && !was_read(art)
  1299. X          && artopen(art) == Nullfp) {    /* never read it, & cannot find it? */
  1300. X          if (errno != ENOENT) {    /* has it not been deleted? */
  1301. X  #ifdef VERBOSE
  1302. X          IF(verbose)
  1303. X
  1304. X--- 320,326 -----
  1305. X      else if
  1306. X        (!reread && !was_read(art)
  1307. X          && artopen(art) == Nullfp) {    /* never read it, & cannot find it? */
  1308. X+ #ifndef SERVER
  1309. X          if (errno != ENOENT) {    /* has it not been deleted? */
  1310. X  #ifdef VERBOSE
  1311. X          IF(verbose)
  1312. X***************
  1313. X*** 306,311
  1314. X          skipstate = 0;
  1315. X          sleep(2);
  1316. X          }
  1317. X          switch(skipstate++) {
  1318. X          case 0:
  1319. X          clear();
  1320. X
  1321. X--- 334,340 -----
  1322. X          skipstate = 0;
  1323. X          sleep(2);
  1324. X          }
  1325. X+ #endif
  1326. X          switch(skipstate++) {
  1327. X          case 0:
  1328. X          clear();
  1329. X***************
  1330. X*** 329,334
  1331. X          default:
  1332. X          putchar('.');
  1333. X          fflush(stdout);
  1334. X  #define READDIR
  1335. X  #ifdef READDIR
  1336. X          {            /* fast skip patch */
  1337. X
  1338. X--- 358,364 -----
  1339. X          default:
  1340. X          putchar('.');
  1341. X          fflush(stdout);
  1342. X+ #ifndef SERVER
  1343. X  #define READDIR
  1344. X  #ifdef READDIR
  1345. X          {            /* fast skip patch */
  1346. X***************
  1347. X*** 341,346
  1348. X              art = newart - 1;
  1349. X          }
  1350. X  #endif
  1351. X          break;
  1352. X          }
  1353. X          oneless(art);        /* mark deleted as read */
  1354. X
  1355. X--- 371,396 -----
  1356. X              art = newart - 1;
  1357. X          }
  1358. X  #endif
  1359. X+ #else
  1360. X+         {
  1361. X+             char    ser_line[256];
  1362. X+             ART_NUM    newart;
  1363. X+ 
  1364. X+             put_server("NEXT");
  1365. X+             if (get_server(ser_line, sizeof (ser_line)) < 0) {
  1366. X+                 fprintf(stderr,
  1367. X+             "rrn: unexpected close of server socket.\n");
  1368. X+                 finalize(1);
  1369. X+             }
  1370. X+             if (ser_line[0] != CHAR_OK)
  1371. X+                 newart = lastart + 1;
  1372. X+             else
  1373. X+                 newart = atoi(ser_line+4);
  1374. X+                 for (i=art; i<newart; i++)
  1375. X+                 oneless(i);
  1376. X+                 art = newart - 1;
  1377. X+         }
  1378. X+ #endif SERVER
  1379. X          break;
  1380. X          }
  1381. X          oneless(art);        /* mark deleted as read */
  1382. X***************
  1383. X*** 450,455
  1384. X      if (artfp != Nullfp) {        /* article still open? */
  1385. X      fclose(artfp);            /* close it */
  1386. X      artfp = Nullfp;            /* and tell the world */
  1387. X      openart = 0;
  1388. X      }
  1389. X      putchar('\n') FLUSH;
  1390. X
  1391. X--- 500,509 -----
  1392. X      if (artfp != Nullfp) {        /* article still open? */
  1393. X      fclose(artfp);            /* close it */
  1394. X      artfp = Nullfp;            /* and tell the world */
  1395. X+ #ifdef SERVER
  1396. X+         sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid);
  1397. X+         UNLINK(artname);
  1398. X+ #endif SERVER
  1399. X      openart = 0;
  1400. X      }
  1401. X      putchar('\n') FLUSH;
  1402. END_OF_FILE
  1403. if test 5064 -ne `wc -c <'./rrnpatches/ng.c.pat'`; then
  1404.     echo shar: \"'./rrnpatches/ng.c.pat'\" unpacked with wrong size!
  1405. fi
  1406. # end of './rrnpatches/ng.c.pat'
  1407. fi
  1408. if test -f './server/netaux.c' -a "${1}" != "-c" ; then 
  1409.   echo shar: Will not clobber existing file \"'./server/netaux.c'\"
  1410. else
  1411. echo shar: Extracting \"'./server/netaux.c'\" \(4765 characters\)
  1412. sed "s/^X//" >'./server/netaux.c' <<'END_OF_FILE'
  1413. X#ifndef lint
  1414. static char    *sccsid = "@(#)netaux.c    1.11    (Berkeley) 2/25/88";
  1415. X#endif
  1416. X
  1417. X/*
  1418. X * Routines to deal with network stuff for
  1419. X * stand-alone version of server.
  1420. X */
  1421. X
  1422. X#include "common.h"
  1423. X#include <sys/socket.h>
  1424. X#include <netinet/in.h>
  1425. X#ifndef EXCELAN
  1426. X#include <netdb.h>
  1427. X#endif not EXCELAN
  1428. X#include <sys/ioctl.h>
  1429. X#include <signal.h>
  1430. X#ifdef USG
  1431. X#include <time.h>
  1432. X#else not USG
  1433. X#include <sys/time.h>
  1434. X#endif USG
  1435. X
  1436. X#ifdef ALONE
  1437. X
  1438. X
  1439. X/*
  1440. X * disassociate this process from the invoker's terminal.
  1441. X * Close all file descriptors, and then open 0, 1, and 2 to
  1442. X * somewhere bogus (i.e., "/", O_RDONLY).  This way we will know
  1443. X * that stdin/out/err will at least be claimed.
  1444. X *
  1445. X *    Parameters:    None.
  1446. X *
  1447. X *    Returns:    Nothing.
  1448. X *
  1449. X *    Side effects:    Disassociates this process from
  1450. X *            a terminal; closes file descriptors;
  1451. X *            fd 0-2 opened as O_RDONLY to /.
  1452. X */
  1453. X
  1454. disassoc()
  1455. X{
  1456. X    register int    i;
  1457. X
  1458. X#ifdef USG
  1459. X    (void) signal(SIGTERM, SIG_IGN);
  1460. X    (void) signal(SIGINT, SIG_IGN);
  1461. X    (void) signal(SIGQUIT, SIG_IGN);
  1462. X#endif
  1463. X
  1464. X    if (fork())
  1465. X        exit(0);
  1466. X
  1467. X    for (i = 0; i < 10; i++)
  1468. X        (void) close(i);
  1469. X
  1470. X#ifdef USG
  1471. X    (void) open("/", 0);
  1472. X    (void) dup2(0, 1);
  1473. X    (void) dup2(0, 2);
  1474. X    setpgrp();
  1475. X    umask(000);
  1476. X#else not USG
  1477. X    i = open("/dev/tty", O_RDWR);
  1478. X    if (i >= 0) {
  1479. X        ioctl(i, TIOCNOTTY, 0);
  1480. X        (void) close(i);
  1481. X    }
  1482. X
  1483. X    i = open("/", O_RDONLY);
  1484. X    if (i >= 0) {
  1485. X        if (i != 0) {            /* should never happen */
  1486. X            (void) dup2(i, 0);
  1487. X            (void) close(i);
  1488. X        }
  1489. X        (void) dup2(0, 1);
  1490. X        (void) dup2(1, 2);
  1491. X    }
  1492. X#endif not USG
  1493. X}
  1494. X
  1495. X
  1496. X/*
  1497. X * get_socket -- create a socket bound to the appropriate
  1498. X *    port number.
  1499. X *
  1500. X *    Parameters:    None.
  1501. X *
  1502. X *    Returns:    Socket bound to correct address.
  1503. X *
  1504. X *    Side effects:    None.
  1505. X *
  1506. X *    Errors:        Syslogd, cause aboriton.
  1507. X */
  1508. X
  1509. get_socket()
  1510. X{
  1511. X    int            s;
  1512. X    struct sockaddr_in    sin;
  1513. X#ifndef EXCELAN
  1514. X    struct servent        *sp;
  1515. X
  1516. X    sp = getservbyname("nntp", "tcp");
  1517. X    if (sp == NULL) {
  1518. X#ifdef SYSLOG
  1519. X        syslog(LOG_ERR, "get_socket: tcp/nntp, unknown service.");
  1520. X#endif
  1521. X        exit(1);
  1522. X    }
  1523. X#endif not EXCELAN
  1524. X
  1525. X    bzero((char *) &sin, sizeof (sin));
  1526. X    sin.sin_family = AF_INET;
  1527. X    sin.sin_addr.s_addr = htonl(INADDR_ANY);
  1528. X#ifndef EXCELAN
  1529. X    sin.sin_port = sp->s_port;
  1530. X
  1531. X    s = socket(AF_INET, SOCK_STREAM, 0);
  1532. X#else EXCELAN
  1533. X    sin.sin_port = htons(IPPORT_NNTP);
  1534. X    s = 3;        /* WTF??? */
  1535. X    s = socket(SOCK_STREAM, (struct sockproto *)0, &sin,
  1536. X        (SO_KEEPALIVE|SO_ACCEPTCONN));
  1537. X#endif EXCELAN
  1538. X    if (s < 0) {
  1539. X#ifdef EXCELAN
  1540. X        sleep(5);
  1541. X        return (-1);
  1542. X#else not EXCELAN
  1543. X#ifdef SYSLOG
  1544. X        syslog(LOG_ERR, "get_socket: socket: %m");
  1545. X#endif SYSLOG
  1546. X        exit(1);
  1547. X#endif not EXCELAN
  1548. X    }
  1549. X
  1550. X#ifndef EXCELAN
  1551. X    if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
  1552. X#ifdef SYSLOG
  1553. X        syslog(LOG_ERR, "get_socket: bind: %m");
  1554. X#endif
  1555. X        exit(1);
  1556. X    }
  1557. X#endif not EXCELAN
  1558. X
  1559. X    return (s);
  1560. X}
  1561. X
  1562. X/*
  1563. X * make_stdio -- make a given socket be our standard input
  1564. X *    and output.
  1565. X *
  1566. X *    Parameters:    "sockt" is the socket we want to
  1567. X *            be file descriptors 0, 1, and 2.
  1568. X *
  1569. X *    Returns:    Nothing.
  1570. X *
  1571. X *    Side effects:    None.
  1572. X */
  1573. X
  1574. make_stdio(sockt)
  1575. X    int    sockt;
  1576. X{
  1577. X    if (sockt != 0) {
  1578. X        (void) dup2(sockt, 0);
  1579. X        (void) close(sockt);
  1580. X    }
  1581. X    (void) dup2(0, 1);
  1582. X    (void) dup2(1, 2);
  1583. X}
  1584. X
  1585. X/*
  1586. X * set_timer -- set up the interval timer so that
  1587. X *    the active file is read in every so often.
  1588. X *
  1589. X *    Parameters:    None.
  1590. X *
  1591. X *    Returns:    Nothing.
  1592. X *
  1593. X *    Side effects:    Sets interval timer to READINTVL seconds.
  1594. X *            Sets SIGALRM to call read_again.
  1595. X */
  1596. X
  1597. set_timer()
  1598. X{
  1599. X#ifndef USG
  1600. X    struct itimerval    new, old;
  1601. X#endif not USG
  1602. X    extern int        read_again();
  1603. X
  1604. X    (void) signal(SIGALRM, read_again);
  1605. X#ifdef USG
  1606. X    alarm(READINTVL);
  1607. X#else not USG
  1608. X
  1609. X    new.it_value.tv_sec = READINTVL;
  1610. X    new.it_value.tv_usec = 0;
  1611. X    new.it_interval.tv_sec = READINTVL;
  1612. X    new.it_interval.tv_usec = 0;
  1613. X    old.it_value.tv_sec = 0;
  1614. X    old.it_value.tv_usec = 0;
  1615. X    old.it_interval.tv_sec = 0;
  1616. X    old.it_interval.tv_usec = 0;
  1617. X
  1618. X    if (setitimer(ITIMER_REAL, &new, &old) < 0) {
  1619. X#ifdef SYSLOG
  1620. X        syslog(LOG_ERR, "set_timer: setitimer: %m\n");
  1621. X#endif SYSLOG
  1622. X        exit(1);
  1623. X    }
  1624. X#endif not USG
  1625. X}
  1626. X
  1627. X
  1628. X/*
  1629. X * read_again -- (maybe) read in the active file again,
  1630. X *    if it's changed since the last time we checked.
  1631. X *
  1632. X *    Parameters:    None (called by interrupt).
  1633. X *
  1634. X *    Returns:    Nothing.
  1635. X *
  1636. X *    Side effects:    May change "num_groups" and "group_array".
  1637. X */
  1638. X
  1639. read_again()
  1640. X{
  1641. X    static long    last_mtime;    /* Last time active file was changed */
  1642. X    struct stat    statbuf;
  1643. X
  1644. X    if (stat(activefile, &statbuf) < 0)
  1645. X        return;
  1646. X
  1647. X    if (statbuf.st_mtime != last_mtime) {
  1648. X        last_mtime = statbuf.st_mtime;
  1649. X        num_groups = read_groups();
  1650. X    }
  1651. X}
  1652. X
  1653. X
  1654. X/*
  1655. X * reaper -- reap children who are ready to die.
  1656. X *    Called by signal.
  1657. X *
  1658. X *    Parameters:    None.
  1659. X *
  1660. X *    Returns:    Nothing.
  1661. X *
  1662. X *    Side effects:    None.
  1663. X */
  1664. X
  1665. reaper()
  1666. X{
  1667. X#ifndef USG
  1668. X    union wait    status;
  1669. X
  1670. X    while (wait3(&status, WNOHANG, (struct rusage *)0) > 0)
  1671. X        ;
  1672. X#endif not USG
  1673. X}
  1674. X
  1675. X#else not ALONE
  1676. X
  1677. X/* Kludge for greenhill's C compiler */
  1678. X
  1679. static
  1680. netaux_greenkludge()
  1681. X{
  1682. X}
  1683. X#endif not ALONE
  1684. END_OF_FILE
  1685. if test 4765 -ne `wc -c <'./server/netaux.c'`; then
  1686.     echo shar: \"'./server/netaux.c'\" unpacked with wrong size!
  1687. fi
  1688. # end of './server/netaux.c'
  1689. fi
  1690. if test -f './server/spawn.c' -a "${1}" != "-c" ; then 
  1691.   echo shar: Will not clobber existing file \"'./server/spawn.c'\"
  1692. else
  1693. echo shar: Extracting \"'./server/spawn.c'\" \(5169 characters\)
  1694. sed "s/^X//" >'./server/spawn.c' <<'END_OF_FILE'
  1695. X#ifndef lint
  1696. static    char    *sccsid = "@(#)spawn.c    1.6    (Berkeley) 2/6/88";
  1697. X#endif
  1698. X
  1699. X#include "../common/conf.h"
  1700. X
  1701. X#include "common.h"
  1702. X
  1703. X#include <signal.h>
  1704. X
  1705. X#ifdef XFER_TIMEOUT
  1706. static int    xfer_lines;
  1707. static int    old_xfer_lines;
  1708. X#endif
  1709. X
  1710. static char    tempfile[256];
  1711. X
  1712. X/*
  1713. X * spawn -- create a child process with the input from the client
  1714. X * as stdin.
  1715. X *
  1716. X *    Parameters:    "path" is the path of the program to invoke.
  1717. X *            "name" is the name to call the program.
  1718. X *            "flag" is a single flag to be passed to the program.
  1719. X *            "cont_code" is the response code to transmit
  1720. X *            on successful startup.
  1721. X *            "err_code" is the response code to transmit when
  1722. X *            something goes wrong.
  1723. X *
  1724. X *    Returns:    -1 on non-zero return from child,
  1725. X *            0 on error before fork/exec,
  1726. X *            1 otherwise.
  1727. X *
  1728. X *    Side effects:    Creates and removes temporary file;
  1729. X *            accepts input from client; forks and execs.
  1730. X *            Can time out if XFER_TIMEOUT is defined.
  1731. X */
  1732. X
  1733. spawn(path, name, flag, cont_code, err_code, errbuf)
  1734. X    char        *path;
  1735. X    char        *name;
  1736. X    char        *flag;
  1737. X    int        cont_code;
  1738. X    int        err_code;
  1739. X    char        *errbuf;
  1740. X{
  1741. X    char        line[NNTP_STRLEN];
  1742. X    register char    *cp;
  1743. X    int        i, fd;
  1744. X    int        fds[2];
  1745. X    int        pid, npid;
  1746. X    int        exit_status;
  1747. X#ifdef XFER_TIMEOUT
  1748. X    int        xfer_timeout();
  1749. X    int        (*otimeout)();
  1750. X#endif
  1751. X#ifdef USG
  1752. X    int        status;
  1753. X#else not USG
  1754. X    union wait    status;
  1755. X#endif not USG
  1756. X    register FILE    *fp;
  1757. X
  1758. X    (void) strcpy(tempfile, "/tmp/rpostXXXXXX");
  1759. X    (void) mktemp(tempfile);
  1760. X
  1761. X    fp = fopen(tempfile, "w");
  1762. X    if (fp == NULL) {
  1763. X        printf("%d Cannot create temporary file.\r\n", err_code);
  1764. X        (void) fflush(stdout);
  1765. X        return (0);
  1766. X    } else {
  1767. X        printf("%d Ok\r\n", cont_code);
  1768. X        (void) fflush(stdout);
  1769. X    }
  1770. X
  1771. X#ifdef XFER_TIMEOUT
  1772. X    xfer_lines = old_xfer_lines = 0;
  1773. X    otimeout = signal(SIGALRM, xfer_timeout);
  1774. X    (void) alarm(XFER_TIMEOUT);
  1775. X#endif
  1776. X
  1777. X    while (fgets(line, sizeof(line), stdin) != NULL) {
  1778. X#ifdef XFER_TIMEOUT
  1779. X        xfer_lines++;
  1780. X#endif
  1781. X        if ((cp = index(line, '\r')) != NULL)
  1782. X            *cp = '\0';
  1783. X        else if ((cp = index(line, '\n')) != NULL)
  1784. X            *cp = '\0';
  1785. X
  1786. X        if (line[0] == '.' && line[1] == '\0')
  1787. X            break;
  1788. X
  1789. X        if (line[0] == '.')
  1790. X            fputs(line+1, fp);
  1791. X        else
  1792. X            fputs(line, fp);
  1793. X        putc('\n', fp);
  1794. X    }
  1795. X    (void) fclose(fp);
  1796. X
  1797. X#ifdef XFER_TIMEOUT
  1798. X    (void) alarm(0);
  1799. X    (void) signal(SIGALRM, otimeout);
  1800. X#endif
  1801. X
  1802. X    /* See if the connection got closed somehow... */
  1803. X
  1804. X    if (line[0] != '.' && line[1] != '\0') {
  1805. X        (void) unlink(tempfile);
  1806. X#ifdef SYSLOG
  1807. X# ifdef LOG
  1808. X        syslog(LOG_ERR, "%s spawn: EOF before period on line by itself",
  1809. X            hostname);
  1810. X# else
  1811. X        syslog(LOG_ERR, "spawn: EOF before period on line by itself");
  1812. X# endif
  1813. X#endif
  1814. X        return (0);
  1815. X    }
  1816. X        
  1817. X#ifdef POSTER
  1818. X    (void) chown(tempfile, uid_poster, gid_poster);
  1819. X#endif
  1820. X
  1821. X    /* Set up a pipe so we can see errors from rnews */
  1822. X
  1823. X    if (pipe(fds) < 0) {
  1824. X#ifdef SYSLOG
  1825. X        syslog(LOG_ERR, "spawn: pipe: %m");
  1826. X#endif
  1827. X        (void) unlink(tempfile);
  1828. X        return (-1);
  1829. X    }
  1830. X
  1831. X    /*
  1832. X     * Ok, now we have the article in "tempfile".  We
  1833. X     * should be able to fork off, close fd's 0 to 31 (or
  1834. X     * whatever), open "tempfile" for input, thus making
  1835. X     * it stdin, and then execl the inews.  We think.
  1836. X     */
  1837. X
  1838. X    pid = vfork();
  1839. X    if (pid == 0) {        /* We're in child */
  1840. X#ifdef POSTER
  1841. X        (void) setuid(uid_poster);
  1842. X        (void) setgid(gid_poster);
  1843. X#endif
  1844. X
  1845. X        /* Set up stdout and stderr for child */
  1846. X
  1847. X        if (fds[1] != 1) {
  1848. X            (void) dup2(fds[1], 1);
  1849. X            (void) close(fds[1]);
  1850. X        }
  1851. X        (void) dup2(1, 2);
  1852. X
  1853. X        for (i = 3; i < 10; ++i) /* XXX but getdtablesize is too big */
  1854. X            (void) close(i);
  1855. X
  1856. X        fd = open(tempfile, O_RDONLY);
  1857. X        if (fd != 0) {
  1858. X            (void) dup2(fd, 0);
  1859. X            (void) close(fd);
  1860. X        }
  1861. X
  1862. X        execl(path, name, flag, (char *) NULL);
  1863. X        fprintf(stderr, "spawn: execl ");
  1864. X        perror(path);
  1865. X        _exit(-1);    /* Error */
  1866. X    } else {
  1867. X        (void) close(fds[1]);
  1868. X        fp = fdopen(fds[0], "r");
  1869. X        if (fp == NULL) {
  1870. X            printf("%d Cannot fdopen %s pipe\r\n", err_code, path);
  1871. X            (void) fflush(stdout);
  1872. X#ifdef SYSLOG
  1873. X            syslog(LOG_ERR, "spawn: pipe: %m");
  1874. X#endif
  1875. X            (void) unlink(tempfile);
  1876. X            return (0);
  1877. X        }
  1878. X
  1879. X        if (errbuf)
  1880. X            *errbuf = '\0';
  1881. X
  1882. X        while (fgets(line, sizeof (line), fp) != NULL) {
  1883. X            if (line[0] != '\n') {
  1884. X                if (errbuf) {
  1885. X                    if (cp = index(line, '\n'))
  1886. X                        *cp = '\0';
  1887. X                    (void) strcat(errbuf, line);
  1888. X                    (void) strcat(errbuf, "\\");
  1889. X                }
  1890. X#ifdef SYSLOG
  1891. X                syslog(LOG_ERR, "%s: %s", path, line);
  1892. X#endif
  1893. X            }
  1894. X        }
  1895. X
  1896. X        while ((npid = wait(&status)) > 0)
  1897. X            if (npid == pid) {
  1898. X#ifdef USG
  1899. X                exit_status = (status >> 8) & 0xff;
  1900. X#else not USG
  1901. X                exit_status = status.w_T.w_Retcode;
  1902. X#endif not USG
  1903. X                break;
  1904. X            }
  1905. X
  1906. X        (void) fclose(fp);
  1907. X        (void) unlink(tempfile);
  1908. X        (void) fflush(stdout);
  1909. X        if (npid < 0) {
  1910. X#ifdef SYSLOG
  1911. X            syslog(LOG_ERR, "spawn: wait pid %d: %m", pid);
  1912. X#endif
  1913. X            return (-1);
  1914. X        }
  1915. X
  1916. X#ifdef SYSLOG
  1917. X        if (exit_status != 0)
  1918. X            syslog(LOG_ERR, "spawn: %s exit status %d",
  1919. X                path, exit_status);
  1920. X#endif
  1921. X            
  1922. X        return (exit_status ? -1 : 1);
  1923. X    }
  1924. X}
  1925. X
  1926. X#ifdef XFER_TIMEOUT
  1927. X
  1928. xfer_timeout()
  1929. X{
  1930. X    if (old_xfer_lines < xfer_lines) {
  1931. X        old_xfer_lines = xfer_lines;
  1932. X        (void) alarm(XFER_TIMEOUT);
  1933. X        return;
  1934. X    }
  1935. X
  1936. X    /* Timed out. */
  1937. X
  1938. X    printf("%d timeout after %d seconds, closing connection.\r\n",
  1939. X        ERR_FAULT, XFER_TIMEOUT);
  1940. X    fflush(stdout);
  1941. X
  1942. X#ifdef LOG
  1943. X    syslog(LOG_ERR, "%s transfer_timeout", hostname);
  1944. X#endif LOG
  1945. X
  1946. X    (void) unlink(tempfile);
  1947. X
  1948. X    exit(1);
  1949. X}
  1950. X
  1951. X#endif XFER_TIMEOUT
  1952. END_OF_FILE
  1953. if test 5169 -ne `wc -c <'./server/spawn.c'`; then
  1954.     echo shar: \"'./server/spawn.c'\" unpacked with wrong size!
  1955. fi
  1956. # end of './server/spawn.c'
  1957. fi
  1958. if test -f './xmit/nntpxmit.1' -a "${1}" != "-c" ; then 
  1959.   echo shar: Will not clobber existing file \"'./xmit/nntpxmit.1'\"
  1960. else
  1961. echo shar: Extracting \"'./xmit/nntpxmit.1'\" \(5838 characters\)
  1962. sed "s/^X//" >'./xmit/nntpxmit.1' <<'END_OF_FILE'
  1963. X.TH NNTPXMIT 1 netnews/NNTP
  1964. X.SH NAME
  1965. X.I nntpxmit
  1966. X\- transmit netnews articles to a remote NNTP server
  1967. X.SH SYNOPSIS
  1968. X.I nntpxmit
  1969. X[
  1970. X.B \-a
  1971. X]
  1972. X[
  1973. X.B \-d
  1974. X]
  1975. X[
  1976. X.B \-s
  1977. X]
  1978. X[
  1979. X.B \-r
  1980. X]
  1981. X[
  1982. X.B \-T
  1983. X]
  1984. X[
  1985. X.B \-F
  1986. X]
  1987. X[
  1988. X.B \-D
  1989. X] hostname|hostname:file [...]
  1990. X.SH DESCRIPTION
  1991. X.PP
  1992. X.I Nntpxmit
  1993. offers netnews articles [RFC850] named in a queue file (a file of
  1994. filenames) to a remote NNTP (Network News Transfer Protocol,
  1995. X[RFC977]) server, transmitting those articles that the remote server
  1996. indicates that it does not already have.
  1997. X.PP
  1998. The command line arguments a processed sequentially, and the flags
  1999. can thus be toggled several times during one invocation of the
  2000. program, by giving the options more than once.
  2001. The options are:
  2002. X.IP hostname|hostname:file
  2003. The name of the remote host, and the name of the queue file of
  2004. articles destined for that host.
  2005. The hostname may be an internet address in dotted
  2006. format (e.g. 10.2.0.78, [10.0.0.78]).
  2007. If the hostname is given without an associated file, it is assumed
  2008. that the hostname is also the name of the queue file.
  2009. If the separator is "::" instead of ":", it is assumed that the
  2010. remote host speaks DECNET, instead of the default, IP/TCP.
  2011. X.IP -s
  2012. Toggles reporting of transfer statistics (how many articles we
  2013. offered them, how many they accepted, etc).
  2014. X.br
  2015. Default is
  2016. X.B ON.
  2017. X.IP -d
  2018. Toggles DEBUG output on stderr.
  2019. This can be used to see exactly what the two systems are saying to
  2020. each other, except for the actual article text.
  2021. X.br
  2022. Default is
  2023. X.B OFF.
  2024. X.IP -r
  2025. Toggles requeuing of failed articles.
  2026. A failed article is an article that we (client) offer them (remote server),
  2027. they accept, we transmit, and then they report that they "failed"
  2028. or dropped the article (i.e. inews(1) on the remote returned non-zero).
  2029. If we have requeuing set, we save the list of articles that they
  2030. failed on, and rewrite the queue file with them, so that they get
  2031. reoffered the next time we initiate transmission to them.
  2032. X.br
  2033. Default is
  2034. X.B ON.
  2035. X.IP -a
  2036. This flag says that the next queue file on the command line isn't
  2037. a queue file, but is a single netnews
  2038. article to be transmitted to the remote in a single operation.
  2039. X.IP
  2040. X.B NOTE:
  2041. this option causes
  2042. X.I nntpxmit
  2043. to exit immediately after this transfer is done (regardless of
  2044. whatever else is on the command line), and to exit with a code
  2045. indicating whether the articles was successfully accepted by the
  2046. remote server (zero exit for success, non-zero for failure).
  2047. X.PP
  2048. The next options set the underlying transport protocol that
  2049. X.I nntpxmit
  2050. uses.
  2051. The NNTP specification assumes a TCP-style transport protocol
  2052. underlies it (i.e. a reliable, flow-controlled, full-duplex byte
  2053. stream).
  2054. X.I Nntpxmit
  2055. assumes that after doing some magic to get a descriptor, 
  2056. it can do read(2) and write(2) calls (and use stdio) to move data
  2057. and check for errors.
  2058. By default, 
  2059. X.I nntpxmit
  2060. will use IP/TCP (DoD Internet Protocol suite).
  2061. X.IP -T
  2062. Sets transport protocol to IP/TCP for all remaining
  2063. transfers (unless reset by other transport flags).
  2064. Default transport.
  2065. X.IP -D
  2066. Sets transport protocol to DECNET for all remaining
  2067. transfers (unless reset by other transport flags).
  2068. X.B NOTE:
  2069. using "::" as the hostname/queue filename separator has the
  2070. same effect.
  2071. X.IP -F
  2072. This says that the hostname is a file descriptor number, already
  2073. open to a remote server (with some reliable protocol underneath)
  2074. that was passed to
  2075. X.I nntpxmit
  2076. through a fork(2).
  2077. X.SH "THEORY OF OPERATION"
  2078. X.PP
  2079. X.I Nntpxmit
  2080. implements an interactive ihave/sendme transmission system.
  2081. Roughly, the protocol is
  2082. X.IP 1.
  2083. open the article,
  2084. fetch out the message-id (required on all netnews articles),
  2085. and send the command IHAVE <message-id> to the remote.
  2086. X.IP 2.
  2087. The remote will then say either "I've seen it already" or "please send
  2088. that article to me."
  2089. X.IP 3.
  2090. If the response was negative,
  2091. X.I nntpxmit
  2092. loops back to step 1 and offers the next article (until queue file EOF).
  2093. Otherwise,
  2094. X.I nntpxmit
  2095. will send the article, using SMTP [RFC821] text transmission conventions
  2096. X(i.e. CRLF line terminators, and dot escaping).
  2097. X.IP 4.
  2098. X.I Nntpxmit
  2099. waits for the remote to say whether the article was successfully
  2100. accepted or not.
  2101. If the answer is negative and requeuing of failed articles is enabled,
  2102. X.I nntpxmit
  2103. will queue this article's filename to be
  2104. written back to the queue file at the end of the session with this
  2105. remote.
  2106. X.PP
  2107. If the communcation link should fail (and
  2108. X.I nntpxmit
  2109. detects it through a system call error return),
  2110. X.I nntpxmit
  2111. will rewrite the queue file with the article filenames of the
  2112. articles that it did not transmit (that is, we don't retransmit
  2113. stuff we've already successfully sent and gotten back an positive
  2114. confirmation that they got it).
  2115. X.SH FILES
  2116. X/tmp/nntpxmitXXXXXX
  2117. X.SH AUTHOR
  2118. Erik E. Fair
  2119. X.SH "SEE ALSO"
  2120. inews(1),
  2121. X.br
  2122. RFC977 \- Network News Transfer Protocol (NNTP),
  2123. X.br
  2124. RFC850 \- USENET Article Format standard,
  2125. X.br
  2126. RFC821 \- Simple Mail Transfer Protocol (SMTP),
  2127. X.SH BUGS
  2128. X.PP
  2129. Always requeuing failed articles can lead to beating the remote to
  2130. death with a list of articles that he can't accept for come structural
  2131. reason.
  2132. How many of these have to pile up before you should declare that
  2133. something is seriously wrong with the remote system and stop trying?
  2134. X.PP
  2135. While
  2136. X.B nntpxmit
  2137. will lock a queue file (your version of UNIX permitting) against
  2138. multiple invocations of itself, there is no locking with inews(1),
  2139. which is what writes the queue files in the first place.
  2140. Therefore, never use
  2141. X.B nntpxmit
  2142. on the queue files that inews(1) writes, because two processes
  2143. writing into the same file without some kind of cooperation will
  2144. almost certainly trash the file; move them to some other name that
  2145. inews(1) knows nothing about, so that you won't lose articles to
  2146. races between inews and nntpxmit.
  2147. X.PP
  2148. Adding inews(1) compatible locking to the C code would be much more
  2149. trouble than it's worth, and violates the KISS principle besides.
  2150. END_OF_FILE
  2151. if test 5838 -ne `wc -c <'./xmit/nntpxmit.1'`; then
  2152.     echo shar: \"'./xmit/nntpxmit.1'\" unpacked with wrong size!
  2153. fi
  2154. # end of './xmit/nntpxmit.1'
  2155. fi
  2156. echo shar: End of archive 4 \(of 9\).
  2157. cp /dev/null ark4isdone
  2158. MISSING=""
  2159. for I in 1 2 3 4 5 6 7 8 9 ; do
  2160.     if test ! -f ark${I}isdone ; then
  2161.     MISSING="${MISSING} ${I}"
  2162.     fi
  2163. done
  2164. if test "${MISSING}" = "" ; then
  2165.     echo You have unpacked all 9 archives.
  2166.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2167. else
  2168.     echo You still need to unpack the following archives:
  2169.     echo "        " ${MISSING}
  2170. fi
  2171. ##  End of shell archive.
  2172. exit 0
  2173.